package ai.people.netmon.framework.businessenum.warning;

import java.util.Arrays;
import java.util.Optional;

/**
 * 预警导出报告类型
 *
 * @author 李冠男
 * @date 2022/5/31 15:57
 */
public enum WarningExportTypeEnum {

    /**
     * 素材
     */
    MATERIAL(1, "素材"),
    /**
     * 话题
     */
    TOPIC(2, "话题"),
    /**
     * 账号
     */
    ACCOUNT(3, "账号"),
    /**
     * 群组
     */
    GROUP(4, "群组"),
    ;

    private final int code;

    private final String name;

    WarningExportTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static WarningExportTypeEnum parseCode(Integer code){
        Optional<WarningExportTypeEnum> first = Arrays.stream(WarningExportTypeEnum.values()).filter(o -> o.getCode() == code).findFirst();
        if(first.isPresent()){
            return first.get();
        }
        return null;
    }
}
